package com.study.exception.handler;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.study.exception.basic.JsonException;
import com.study.exception.basic.PageException;
import com.study.exception.constant.Status;

@Controller
public class TestController {
	
	

	@ResponseBody
	@GetMapping("/testJson")
	public String testJson() {
		//controller中不能捕获异常，否则@ControllerAdvice标注
		//的异常处理类中的处理不起效果
//		try {
			throw new JsonException(Status.UNKNOWN_ERROR);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return "success";
	}
	
	@GetMapping("/testPage")
	public String testPage() {
//		try {
			throw new PageException(Status.UNKNOWN_ERROR);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return "success";
	}
}
